var showCharts;
require(['highcharts'], function () {
	showCharts = function(lineId,organId,rcrdTime,
			idliDuraRate,airCondiIdliDuraRate,slowSpdRevoDuraRate,lowEnerAreaDriveDuraRate,highSpdRevoDuraRate,
	        suspeedDuraRate,mostEcnRtteSpdDuraRate,revDuraRate,
			licPltNo,drvName,lineName,organName,fuelType, beginTime, endTime, addDrv){
		
		var _idliDuraRate = parseFloat(idliDuraRate.substring(0,idliDuraRate.indexOf('%')))||0;
		var _airCondiIdliDuraRate = parseFloat(airCondiIdliDuraRate.substring(0,airCondiIdliDuraRate.indexOf('%')))||0;
		var _slowSpdRevoDuraRate = parseFloat(slowSpdRevoDuraRate.substring(0,slowSpdRevoDuraRate.indexOf('%')))||0;
		var _lowEnerAreaDriveDuraRate = parseFloat(lowEnerAreaDriveDuraRate.substring(0,lowEnerAreaDriveDuraRate.indexOf('%')))||0;
		var _highSpdRevoDuraRate = parseFloat(highSpdRevoDuraRate.substring(0,highSpdRevoDuraRate.indexOf('%')))||0;
		var _suspeedDuraRate = parseFloat(suspeedDuraRate.substring(0,suspeedDuraRate.indexOf('%')))||0;
		var _mostEcnRtteSpdDuraRate = parseFloat(mostEcnRtteSpdDuraRate.substring(0,mostEcnRtteSpdDuraRate.indexOf('%')))||0;
		var _revDuraRate = parseFloat(revDuraRate.substring(0,revDuraRate.indexOf('%')))||0;
		
		var _otherRate = 100 - _idliDuraRate - _airCondiIdliDuraRate - _slowSpdRevoDuraRate - _lowEnerAreaDriveDuraRate
			- _highSpdRevoDuraRate - _suspeedDuraRate - _mostEcnRtteSpdDuraRate - _revDuraRate;
		
		
		$("#lineAnalysisChart").empty();
		$("#speedAnalysisChart").empty();
//		var addDrv = $("#addDrv").val();
//		var temp="";
//		if(addDrv!="1"){
//			$("#drvOrCar").text(licPltNo);
//			temp=licPltNo;
//		}else{
//			$("#drvOrCar").text(drvName); 
//			temp=drvName;
//		}
//		var titleStr = "";
//		if(lineId == "" || lineId == "null") {
//			lineId = "";
//			titleStr = organName;
//		} else {
//			titleStr = lineName;
//		}
		//线路平均
		 var params = [];
		 params.push({
			name : "beginTime",
			value : beginTime
		},{
			name : "endTime",
			value : endTime
		},{
			name : "lineId",
			value : lineId
		},{
			name : "organId",
			value : organId
		},{
			name : "fuelTypeCode",
			value : fuelType
		});
		$.ajaxExt({
			url : "/speedAnalysis/searchLineEnergyChart.htm",
			data : params
		}).done(function(result){
			var line_idliDuraRate = parseFloat(result[0].idliDuraRate.substring(0,result[0].idliDuraRate.indexOf('%')))||0;
			var line_airCondiIdliDuraRate = parseFloat(result[0].airCondiIdliDuraRate.substring(0,result[0].airCondiIdliDuraRate.indexOf('%')))||0;
			var line_slowSpdRevoDuraRate = parseFloat(result[0].slowSpdRevoDuraRate.substring(0,result[0].slowSpdRevoDuraRate.indexOf('%')))||0;
			var line_lowEnerAreaDriveDuraRate = parseFloat(result[0].lowEnerAreaDriveDuraRate.substring(0,result[0].lowEnerAreaDriveDuraRate.indexOf('%')))||0;
			var line_highSpdRevoDuraRate = parseFloat(result[0].highSpdRevoDuraRate.substring(0,result[0].highSpdRevoDuraRate.indexOf('%')))||0;
			var line_suspeedDuraRate = parseFloat(result[0].suspeedDuraRate.substring(0,result[0].suspeedDuraRate.indexOf('%')))||0;
			var line_mostEcnRtteSpdDuraRate = parseFloat(result[0].mostEcnRtteSpdDuraRate.substring(0,result[0].mostEcnRtteSpdDuraRate.indexOf('%')))||0;
			var line_revDuraRate = parseFloat(result[0].revDuraRate.substring(0,result[0].revDuraRate.indexOf('%')))||0;
			
			var line_otherRate = 100 - line_idliDuraRate - line_airCondiIdliDuraRate - line_slowSpdRevoDuraRate - line_lowEnerAreaDriveDuraRate
				- line_highSpdRevoDuraRate - line_suspeedDuraRate - line_mostEcnRtteSpdDuraRate - line_revDuraRate;
			
			$("#lineAnalysisChart").highcharts({
		        chart: {
		            plotBackgroundColor: null,
		            plotBorderWidth: null,
		            plotShadow: false
		        },
		        colors:['#4D526D','#A78B5A','#FEE303','#B7E138','#F29B42','#ED4747','#50E138','#1B9784', "#0000FF"],
		        title: {
		            text: '线路平均转速分析'
		        },
		        credits: {
		            enabled: false
		        },
		        plotOptions: {
		        	pie: {
		                allowPointSelect: true,
		                cursor: 'pointer',
		                // innerSize: '0%',
		                dataLabels: {
		                	 enabled: false
		                },
		                distance: -30,
		                showInLegend: true
		            }
		        },
		        tooltip: {
		            pointFormat: '{series.name}: <b>{point.percentage:.2f}%</b>'
		        },
		        legend: {
		            borderWidth: 0
		        },
		        series: [
		            {
		                type: 'pie',
		                name: '转速分析',
		                data: [
		                    ['怠速时长', line_idliDuraRate],
								['空调怠速时长', line_airCondiIdliDuraRate],
								['低转时长', line_slowSpdRevoDuraRate],
								['绿区时长', line_lowEnerAreaDriveDuraRate],
								['高转时长', line_highSpdRevoDuraRate],
								['超转时长', line_suspeedDuraRate],
								['最经济转速时长', line_mostEcnRtteSpdDuraRate],
								['反转时长', line_revDuraRate],
								['其他转速时长', line_otherRate]
		                  ]
		            }
		        ]
		    });
		});
		//单台车/单个驾驶员
		$("#speedAnalysisChart").highcharts({
	        chart: {
	            plotBackgroundColor: null,
	            plotBorderWidth: null,
	            plotShadow: false
	        },
	        colors:['#4D526D','#A78B5A','#FEE303','#B7E138','#F29B42','#ED4747','#50E138','#1B9784', "#0000FF"],
	        title: {
	            text: '转速分析'
	        },
	        credits: {
	            enabled: false
	        },
	        plotOptions: {
	        	pie: {
	                allowPointSelect: true,
	                cursor: 'pointer',
	                // innerSize: '0%',
	                dataLabels: {
	                	 enabled: false
	                },
	                distance: -30,
	                showInLegend: true
	            }
	        },
	        tooltip: {
	            pointFormat: '{series.name}: <b>{point.percentage:.2f}%</b>'
	        },
	        legend: {
	            borderWidth: 0
	        },
	        series: [
	            {
	                type: 'pie',
	                name: '转速分析',
	                data: [
	                        ['怠速时长', _idliDuraRate],
							['空调怠速时长', _airCondiIdliDuraRate],
							['低转时长', _slowSpdRevoDuraRate],
							['绿区时长',_lowEnerAreaDriveDuraRate],
							['高转时长', _highSpdRevoDuraRate],
							['超转时长',_suspeedDuraRate],
							['最经济转速时长', _mostEcnRtteSpdDuraRate],
							['反转时长', _revDuraRate],
							['其他转速时长', _otherRate]
	                ]
	            }
	        ]
	    }); 
//		$("#speedAnalysisDialog").dialog({title: '【' + titleStr+' > '+ temp +'】转速分析       运营日期: '+ rcrdTime+''});
//		$("#speedAnalysisDialog").dialog('open'); 
		
		
	};
});